﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace DevelopTools.UI
{
    /// <summary>
    /// 点击事件的Button
    /// </summary>
    [RequireComponent(typeof(UnityEngine.UI.Button))]
    public class ClickButtonShowUI : MonoBehaviour
    {

        public GameObject objUI;

        public bool isShow;
        Text thisText;
        void Start()
        {
            transform.GetComponent<Button>().onClick.AddListener(delegate { ShowUI(); });
            thisText = transform.Find("Text").GetComponent<Text>();
        }

        void ShowUI()
        {
            isShow = !isShow;
            objUI.SetActive(isShow);
            if (isShow)
            {
                thisText.text = "back";
                UIStateControl.instance.mStateCarr = UIStateControl.StateCarR.ShowUI;

            }
            else
            {

                thisText.text = "info";

                UIStateControl.instance.mStateCarr = UIStateControl.StateCarR.Normal;
            }
        }

        private void OnDisable()
        {
            objUI.SetActive(false);
            isShow = false;
        }


    }
}